package com.wowudi.controller;

import com.wowudi.dto.Result;
import com.wowudi.entity.Department;
import com.wowudi.mapper.DepartmentMapper;
import com.wowudi.service.DepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "部门管理")
@RequestMapping("api/dept/dept")
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;
    @Autowired
    private DepartmentMapper departmentMapper;


    @ApiOperation(value = "根据id查询部门信息")
    @GetMapping("getDepartment/{id}")
    public Result getDepartment(@PathVariable("id") long id){
        Department department = departmentService.findDepartmentById(id);
        Result result = new Result();
        result.setData(department);
        return result;
    }


    @ApiOperation(value = "查询所有部门信息")
    @GetMapping("getDepartmentAll")
    public Result getDepartmentAll(){
        List<Department> departmentList = departmentService.findDepartmentAll();
        Result result = new Result();
        result.setData(departmentList);
        return result;
    }

    @RequestMapping("depart")
    public List selectdepart() {
        List<Department> list = departmentMapper.selectList(null);
        return list;
    }
}
